from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModPowerSupplyBureauList import PowerSupplyBureauList, bureauListSchema
from database import Session, engine
import datetime


def get_bureau_info(session,bureauid: str):
    #县局信息
        bureau_info = session.query(PowerSupplyBureauList).filter(PowerSupplyBureauList.id == bureauid).one_or_none()
        return JSONResponse(bureauListSchema.dump(bureau_info, many=False).data)

def get_bureau_info_all(session):
    #县局所有信息
        bureau_info = session.query(PowerSupplyBureauList).all()
        return JSONResponse(bureauListSchema.dump(bureau_info, many=True).data)

def get_bureau_info_sent(session,bureauid: str):
    #县局信息
        bureau_info = session.query(PowerSupplyBureauList).filter(PowerSupplyBureauList.id == bureauid).one_or_none()
        return bureauListSchema.dump(bureau_info, many=False).data